<template>
	<div class="container">
		<div class="title">
			 <el-button type="primary" size="small" class="btn1"  @click="cancel" icon="search">返回</el-button>
		</div>
		<div class="title">
			<!-- <el-button type="text" class="back" @click="cancel">返回</el-button> -->
			<h2>{{top}}的学生</h2>
		</div>
        <i class="el-icon-close close-top" @click="cancel"></i>


		<!-- 数据表格展示区域 -->
        <el-table
            :data="dataList"
             stripe
             border
            align="center"
            class="admin-table">



            <el-table-column
                :prop="v.prop"
                :label="v.label"
                v-for="(v,index) in portTitleList"
                align="center"
                show-overflow-tooltip
                v-if="v.hide != 0"
                :align="v.align || 'center'"
                :fixed="v.fixed"
                :formatter="v.formatter"
                :class-name="v.columnStyle"
                :width="v.width"
                :min-width="v.minWidth || '150'"
                :header-align="v.headerAlign || 'center'"
                >
            </el-table-column>

            <!-- <el-table-column
                label="操作"
                width="200"
                align="center"
                fixed="right">
                <template scope="scope">
                    <el-button size="small" type="text" @click="componentsFn(v.type)" v-for="v in portBntList">{{v.name}}</el-button>
                </template>
            </el-table-column> -->
						<!-- <el-table-column   fixed="right" label="操作" width="100" align="center"  >
                <template scope="scope">
										<el-button size="small" type="text"  v-if="false"   @click="componentsShow('pjadd',scope)">评价</el-button>
                   <el-button size="small" type="text"  v-if="false"   @click="componentsShow('bkadd',scope)">补课</el-button>
                   <el-button size="small" type="text"  v-if="false"   @click="componentsShow('pjinfo',scope)">查看评价</el-button>
                </template>
            </el-table-column> -->

        </el-table>
				<BkaddComponent v-if="componentList.bkadd.toggle"   @close="componentsHide"  :params="componentList.bkadd.params"></BkaddComponent>
				<PjaddComponent v-if="componentList.pjadd.toggle"   @close="componentsHide"  :params="componentList.pjadd.params"></PjaddComponent>
				<PjinfoComponent v-if="componentList.pjinfo.toggle" @close="componentsHide"  :params="componentList.pjinfo.params"></PjinfoComponent>


        <!-- <el-dialog
            title="提示"
            :modal-append-to-body="false"
            :visible.sync="dialogVisible"
            size="tiny">
            <el-button type="info" class="submit" @click="submit">确认</el-button>
        </el-dialog> -->
				<!-- <router-view class="port-view"></router-view> -->
	</div>
</template>

<script type="text/javascript">
	import qs from 'qs'
import BkaddComponent from './bkadd'
import PjaddComponent from './pjadd'
import PjinfoComponent from './pjinfo'
	export default {
        props: ['params'],
				components: {
						BkaddComponent,
						PjaddComponent,
						PjinfoComponent
				},
		data () {
			return {
				top:'',
				isReplace: false,
                dialogVisible: false,


                teacherList: [],
                form: {
                    studentname:'',
                    studentlj:'',
                    studentclass:''
                },

                dataList: [],  //表格数据
								  componentList: {
										bkadd: {
												type: 'bkadd',
												toggle: false,
												params: '',
												data: {}
										},
										pjadd: {
												type: 'pjadd',
												toggle: false,
												params: '',
												data: {}
										},
										pjinfo: {
												type: 'pjinfo',
												toggle: false,
												params: '',
												data: {}
										},

									},
                portTitleList: [
                    {
                        prop:'name',
                        label:'学生中文名',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center'
                    },
                    {
                        prop:'ename',
                        label:'学生英文名',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center',
                    },
										{
                        prop:'bjlsmc',
                        label:'老师名称',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center'
                    },
                    {
                        prop:'bjmc',
                        label:'班级名称',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center'
                    },
                    {
                        prop:'kqztmc',
                        label:'考勤状态',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center'
                    },
                    {
                        prop:'pjzt',
                        label:'评价状态',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center'
                    },
                    {
                        prop:'day',
                        label:'day',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center'
                    },

                 ],
                // portBntList: [//接口按钮列表
                //     {
                //         name:'编辑',
                //         type:'edit'
                //     },
                //     {
                //         name:'删除',
                //         type:'singleDelete'
                //     },
                // ],

			}
		},
        created () {
            console.log(this.params);
             if(this.$route.query.bjmc) {
//				alert(this.params.row.mc)
								this.top=this.$route.query.bjmc;
							}else{
								this.top=this.params.row.bjmc;
							}
				    if(this.$route.query.iid){
								this.bjid=this.$route.query.iid;
							}else{
								this.bjid=this.params.row.bjid;
						}
            this.getCourseList();
            // this.$store.dispatch('getTeacherList');
        },
		methods: {
			cancel () {
				this.$emit('close',{type:'student',cancel:true})
			},

            submit () {
            	var logininfo = JSON.parse(localStorage.logininfo);
              this.searchLoading = true;
             var params2 = qs.stringify({
                      name: this.form.studentname,
                        nj: this.form.studentnj,
                        bj: this.form.studentclass
               })
             //执行
                 this.axios.post(this.$store.state.api + 'dk/add',  params2 )
                 .then(res => {
					console.log(this.dataList)
                 }).catch(res => {
					 console.log(res);
				})
            	
            	
            	
//              console.log(this.form.teachers)
//              this.dialogVisible = false;
//              this.axios.get(this.$store.state.api + 'dk/add', {
//                  params: {
//                      name: this.form.studentname,
//                      nj: this.form.studentnj,
//                      bj: this.form.studentclass
//                  }
//              }).then ( res => {
//                  console.log(res)
//              }).catch( res => {
//                  console.log(res)
//              })
            },
            supplyCourse(scope) {
                console.log(scope)
                this.dialogVisible = true;
                this.form.classroomName = scope.row.jsmc;
                this.form.classroomID = scope.row.id
            },

            getCourseList () {
            	var logininfo = JSON.parse(localStorage.logininfo);
              this.searchLoading = true;
             var params2 = qs.stringify({
                      yhid:logininfo.id,
						xxid:logininfo.xxid,
                        bjid: this.bjid,
                        day: this.params.row.xh
               })
             //执行
                 this.axios.post(this.$store.state.api + 'pk/Pkpkxslist',  params2 )
                 .then(res => {
                 this.$store.state.loading = false;
                    this.dataList = res.data.data.list;
					console.log(this.dataList)
                 }).catch(res => {
					 console.log(res);
                    this.$store.dispatch('showAlert',res.data.msg);
                    this.$store.state.loading = false;
				})
            	
            	
            	
            	
//              this.$store.state.loading = true;
//				var logininfo = JSON.parse(localStorage.logininfo);
//              this.axios.get(this.$store.state.api + 'pk/Pkpkxslist', {
//                  params: {
//						yhid:logininfo.id,
//						xxid:logininfo.xxid,
//                      bjid: this.bjid,
//                      day: this.params.row.xh
//                  }
//              }).then ( res => {
//                  this.$store.state.loading = false;
//                  this.dataList = res.data.data.list;
//					console.log(this.dataList)
//              }).catch( res => {
//                  console.log(res);
//                  this.$store.dispatch('showAlert',res.data.msg);
//                  this.$store.state.loading = false;
//              })
            },
						componentsHide (setting) { //关闭组件
								for ( let i in this.componentList ) {
										if (setting.type == this.componentList[i].type) {
												this.componentList[i].toggle = false;

												if (!setting.cancel) {
													 this.search();
												}
												return;
										}
								}
						},
						componentsShow (type,data) { //显示组件
                console.log(type,data)
                for ( let i in this.componentList ) {
                    if (type == this.componentList[i].type) {
                        this.componentList[i].toggle = true;
                        this.componentList[i].params = data;
                        if (this.componentList[i].data.type == 'single') {
                            this.componentList[i].data.index = data.row.id
                        }else if(this.componentList[i].data.type == 'multiple'){
                            this.componentList[i].data.index = this.multipleDelNum;
                        }else{
                            return;
                        }
                        return;
                    }
                }
            },
            // componentsFn (type) {
            //     if (type == "replace") {
            //         this.isReplace = true;
            //     }
            // },
            close (bol) {
                // console.log(bol)
                if (bol) {
                    this.isReplace = false;
                }
            }
		}
	}
</script>

<style lang="less" scoped>
.container{
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	.title {
		h2 {
		    margin-left: 45%;
			line-height: 50px;
			font-size:25px;
			text-align: center;
			display: inline-block;
		}
		.btn1 {
		text-align: left;
		margin-left: 10px;
		 margin-top: 10px;
	}
	}

    .submit {
        width: 120px;
        display: block;
        margin:0 auto;
    }
    }
</style>
